<?php

echo "All accounts in DB($user_count_in_db)";


echo '<table id="sum-info-table" cellspacing="0">';
echo "<tr><td>Followed By</td><td>Following</td><td>Tweet</td></tr>";

if (isset($show_dead)) {
  $sql = 
"select sum(A.followed) as followed, sum(A.following) as following, sum(A.tweet) as tweet 
from
(select user, max(followed_count) as followed, max(follow_count) as following, max(tweet_count) as tweet, max(collect_date) as date
from user_statistic 
group by user) as A 
where A.date <> '$today'";

} else {
$sql = sprintf("select sum(followed_count) as followed, sum(follow_count) as following, sum(tweet_count) as tweet
from user_statistic 
where collect_date = '$today'");
}


$ret = mysql_query($sql);

if (!$ret) {
  echo $sql;
  echo mysql_error();
  return;
}

//echo mysql_num_rows($ret) . "<hr />";
while ($account = mysql_fetch_assoc($ret)) {
  $row = sprintf("<td>%d</td><td>%d</td><td>%d</td>",
                 $account['followed'], $account['following'], $account['tweet']);
  echo "<tr>$row</tr>";
}
echo '</table>';
?>